package constant.milk.periodapp.dialog;

import constant.milk.periodapp.R;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MilkYesNoDialog extends Dialog
{
	private TextView titleTextView;
	private TextView messageTextView;
	private TextView noTextView;
	private TextView yesTextView;
	
	private String title;
	private String message;
	
	private String leftText;
	private String rightText;
	
	private View.OnClickListener yesListener;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.dialog_yesno);
		
		titleTextView = (TextView) findViewById(R.id.dialogYesNoTitleTextView);
		messageTextView = (TextView) findViewById(R.id.dialogYesNoMessageTextView);
		noTextView = (TextView) findViewById(R.id.dialogNoTextView);
		yesTextView = (TextView) findViewById(R.id.dialogYesTextView);
		
		titleTextView.setText(title);
		messageTextView.setText(message);
		
		if (!leftText.equals(""))
		{
			noTextView.setText(leftText);
		}
		
		if (!rightText.equals(""))
		{
			yesTextView.setText(rightText);
		}
		
		noTextView.setOnClickListener(new View.OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				dismiss();
			}
		});
		
		yesTextView.setOnClickListener(yesListener);
	}

	public MilkYesNoDialog(Context context, String title, String message, View.OnClickListener yesListener)
	{
		super(context, android.R.style.Theme_Translucent_NoTitleBar);
		this.title = title;
		this.message = message;
		this.yesListener = yesListener;
		this.leftText = "";
		this.rightText = "";
	}
	
	public void setLeftTitle(String text)
	{
		this.leftText = text;
	}
	
	public void setRightTitle(String text)
	{
		this.rightText = text;
	}
}
